import {
  C0LUMNS,
  PAY_USE,
  ISDELAYPAY_TYPE,
  BUS_MODEL,
  PAYMENT_STATUS
} from './index.const';
import {
  findPaymentByOrderId,
  orderProductList
} from '@api/m_mall_web_v1.js';
import ElEditable from '@components/el-editable';
export default {
  components: {
    ElEditable
  },
  inject: ['apiMMallWeb'],
  data() {
    return {
      PAY_USE,
      ISDELAYPAY_TYPE,
      BUS_MODEL,
      PAYMENT_STATUS,
      currentPage: 1,
      pageSize: 20,
      tableLoading: false,
      payload: {},
      C0LUMNS,
      detailData: {}
    };
  },
  async created() {
    this.getDetail()

  },
  computed: {
    orderId() {
      return this.$route.query.orderId;
    },
    orderStatus() {
      return this.$route.query.orderStatus;
    },
  },
  methods: {
    //获取详情
    getDetail() {
      this.$axios.$get(`${findPaymentByOrderId}?orderId=${this.orderId}`).then(res => {
        if (res.payload) {
          let payload = res.payload
          payload.payUse ? payload.payUse = PAY_USE[payload.payUse] : payload.payUse = '-'
          payload.busModel ? payload.busModel = BUS_MODEL[payload.busModel] : payload.busModel = '-'
          payload.paymentStatus ? payload.paymentStatus = PAYMENT_STATUS[payload.paymentStatus] : payload.paymentStatus = '无'
          this.detailData = payload
          this.getDetailList()

        }
      })
    },
    //获取详情商品列表
    getDetailList() {
      this.tableLoading = true
      this.$axios.$post(orderProductList, {
        orderDetailId: this.detailData.orderDetailId,
        page: this.currentPage,
        pageSize: this.pageSize
      }).then(res => {
        this.payload = res.payload;
        this.tableLoading = false
      })
    },
    reloadPagination(val) {
      this.currentPage = val.number
      this.pageSize = val.size
      this.getDetailList()
    }
  }
};